{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b31e38f8",
   "metadata": {},
   "source": [
    "# 匿名函数与map方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6e3df941",
   "metadata": {},
   "source": [
    "### 匿名函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d4b9ec83",
   "metadata": {},
   "outputs": [],
   "source": [
    "my_func = lambda x: 2*x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e10674af",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my_func(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7438fb49",
   "metadata": {},
   "outputs": [],
   "source": [
    "ll = lambda a, b: a + b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9b4f9bbe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ll(1, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e673ca88",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 2, 4, 6, 8]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[(lambda x: 2*x)(i) for i in range(5)]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce74334e",
   "metadata": {},
   "source": [
    "### map方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "71d89ce2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 2, 4, 6, 8]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(map(lambda x: 2*x,range(5)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "3993bd9b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['0_a', '1_b', '2_c', '3_d']"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(map(lambda x, y: str(x)+'_'+y, range(5), list('abcd')))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "dd4d4129",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 学生练习\n",
    "name = ['小明','小红','李华']\n",
    "age = [18,19,17]\n",
    "\n",
    "# 希望得到效果：\n",
    "# ['小明_18','小红_19','李华_17']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0ed8b407",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['小明_18', '小红_19', '李华_17']"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(map(lambda x,y:x+'_'+str(y),name,age))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2e9cdca5",
   "metadata": {},
   "source": [
    "# zip对象与enumerate方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8c4f08e5",
   "metadata": {},
   "source": [
    "### zip方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "c227df96",
   "metadata": {},
   "outputs": [],
   "source": [
    "L1,L2,L3 = list('abc'),list('def'),list('hij')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "275922bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('a', 'd', 'h'), ('b', 'e', 'i'), ('c', 'f', 'j')]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(zip(L1,L2,L3))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1efd3ff2",
   "metadata": {},
   "source": [
    "### enumerate 方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "33ebb2cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 a\n",
      "1 b\n",
      "2 c\n",
      "3 d\n"
     ]
    }
   ],
   "source": [
    "特殊 = list('abcd')\n",
    "for index, zhi in enumerate(特殊):\n",
    "    print(index, zhi)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a9793e2",
   "metadata": {},
   "source": [
    "# 文件的读取和写入（p27)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ebc3313a",
   "metadata": {},
   "source": [
    "### 数据读取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "216cd010",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "f799f478",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col1</th>\n",
       "      <th>col2</th>\n",
       "      <th>col3</th>\n",
       "      <th>col4</th>\n",
       "      <th>col5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>a</td>\n",
       "      <td>1.4</td>\n",
       "      <td>apple</td>\n",
       "      <td>2020/1/1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3</td>\n",
       "      <td>b</td>\n",
       "      <td>3.4</td>\n",
       "      <td>banana</td>\n",
       "      <td>2020/1/2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6</td>\n",
       "      <td>c</td>\n",
       "      <td>2.5</td>\n",
       "      <td>orange</td>\n",
       "      <td>2020/1/5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>d</td>\n",
       "      <td>3.2</td>\n",
       "      <td>lemon</td>\n",
       "      <td>2020/1/7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   col1 col2  col3    col4      col5\n",
       "0     2    a   1.4   apple  2020/1/1\n",
       "1     3    b   3.4  banana  2020/1/2\n",
       "2     6    c   2.5  orange  2020/1/5\n",
       "3     5    d   3.2   lemon  2020/1/7"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv('/学/2022-2023-02/python数据分析/data/my_csv.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "a17fed6d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>col1</td>\n",
       "      <td>col2</td>\n",
       "      <td>col3</td>\n",
       "      <td>col4</td>\n",
       "      <td>col5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>a</td>\n",
       "      <td>1.4</td>\n",
       "      <td>apple</td>\n",
       "      <td>2020/1/1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>b</td>\n",
       "      <td>3.4</td>\n",
       "      <td>banana</td>\n",
       "      <td>2020/1/2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>6</td>\n",
       "      <td>c</td>\n",
       "      <td>2.5</td>\n",
       "      <td>orange</td>\n",
       "      <td>2020/1/5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>d</td>\n",
       "      <td>3.2</td>\n",
       "      <td>lemon</td>\n",
       "      <td>2020/1/7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      0     1     2       3         4\n",
       "0  col1  col2  col3    col4      col5\n",
       "1     2     a   1.4   apple  2020/1/1\n",
       "2     3     b   3.4  banana  2020/1/2\n",
       "3     6     c   2.5  orange  2020/1/5\n",
       "4     5     d   3.2   lemon  2020/1/7"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv('/学/2022-2023-02/python数据分析/data/my_csv.csv',header=None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "e1071c33",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col2</th>\n",
       "      <th>col3</th>\n",
       "      <th>col4</th>\n",
       "      <th>col5</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>col1</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>a</td>\n",
       "      <td>1.4</td>\n",
       "      <td>apple</td>\n",
       "      <td>2020/1/1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>b</td>\n",
       "      <td>3.4</td>\n",
       "      <td>banana</td>\n",
       "      <td>2020/1/2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>c</td>\n",
       "      <td>2.5</td>\n",
       "      <td>orange</td>\n",
       "      <td>2020/1/5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>d</td>\n",
       "      <td>3.2</td>\n",
       "      <td>lemon</td>\n",
       "      <td>2020/1/7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     col2  col3    col4      col5\n",
       "col1                             \n",
       "2       a   1.4   apple  2020/1/1\n",
       "3       b   3.4  banana  2020/1/2\n",
       "6       c   2.5  orange  2020/1/5\n",
       "5       d   3.2   lemon  2020/1/7"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv('/学/2022-2023-02/python数据分析/data/my_csv.csv',index_col=\"col1\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dd81a50d",
   "metadata": {},
   "source": [
    "* 重要的文件读取方法（特殊格式文件）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "db612e3d",
   "metadata": {},
   "source": [
    "> 1.sep()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "4769c490",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col1 |||| col2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TS |||| This is an apple.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>GQ |||| My name is Bob.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>WT |||| Well done!</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>PT |||| May I help you?</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              col1 |||| col2\n",
       "0  TS |||| This is an apple.\n",
       "1    GQ |||| My name is Bob.\n",
       "2         WT |||| Well done!\n",
       "3    PT |||| May I help you?"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_table('/学/2022-2023-02/python数据分析/data/my_table_special_sep.txt')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "959a1b02",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col1</th>\n",
       "      <th>col2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TS</td>\n",
       "      <td>This is an apple.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>GQ</td>\n",
       "      <td>My name is Bob.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>WT</td>\n",
       "      <td>Well done!</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>PT</td>\n",
       "      <td>May I help you?</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  col1                 col2\n",
       "0   TS    This is an apple.\n",
       "1   GQ      My name is Bob.\n",
       "2   WT           Well done!\n",
       "3   PT      May I help you?"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_table('/学/2022-2023-02/python数据分析/data/my_table_special_sep.txt',sep='\\|\\|\\|\\|',engine=\"python\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "0765de66",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "6778eca9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>国家</td>\n",
       "      <td>独角兽数量（变化）</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>城市</td>\n",
       "      <td>独角兽数量（变化）</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1-</td>\n",
       "      <td>美国</td>\n",
       "      <td>625 (+138)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1-</td>\n",
       "      <td>旧金山</td>\n",
       "      <td>176 (+25)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2-</td>\n",
       "      <td>中国</td>\n",
       "      <td>312 (+11)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2↑</td>\n",
       "      <td>纽约</td>\n",
       "      <td>120 (+35)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3-</td>\n",
       "      <td>印度</td>\n",
       "      <td>68 (+14)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3↓</td>\n",
       "      <td>北京</td>\n",
       "      <td>90 (-1)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4-</td>\n",
       "      <td>英国</td>\n",
       "      <td>46 (+7)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4-</td>\n",
       "      <td>上海</td>\n",
       "      <td>69 (-2)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5-</td>\n",
       "      <td>德国</td>\n",
       "      <td>36 (+10)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5↑</td>\n",
       "      <td>伦敦</td>\n",
       "      <td>39 (+8)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>6↑</td>\n",
       "      <td>以色列</td>\n",
       "      <td>24 (+7)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6↓</td>\n",
       "      <td>深圳</td>\n",
       "      <td>33 (+1)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>7↓</td>\n",
       "      <td>法国</td>\n",
       "      <td>23 (+4)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6↑</td>\n",
       "      <td>班加罗尔</td>\n",
       "      <td>33 (+5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>8-</td>\n",
       "      <td>加拿大</td>\n",
       "      <td>21 (+6)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>8↑</td>\n",
       "      <td>柏林</td>\n",
       "      <td>23 (+6)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>9-</td>\n",
       "      <td>巴西</td>\n",
       "      <td>17 (+5)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9↓</td>\n",
       "      <td>杭州</td>\n",
       "      <td>21 (-1)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>10-</td>\n",
       "      <td>韩国</td>\n",
       "      <td>15 (+5)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9-</td>\n",
       "      <td>巴黎</td>\n",
       "      <td>21 (+3)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>11-</td>\n",
       "      <td>新加坡</td>\n",
       "      <td>12 (+5)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11↑</td>\n",
       "      <td>帕洛阿尔托</td>\n",
       "      <td>19 (+7)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>12↑</td>\n",
       "      <td>瑞典</td>\n",
       "      <td>8 (+4)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11↑</td>\n",
       "      <td>广州</td>\n",
       "      <td>19 (+9)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>12↑</td>\n",
       "      <td>日本</td>\n",
       "      <td>8 (+2)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>13↓</td>\n",
       "      <td>波士顿</td>\n",
       "      <td>17 (+5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>12↑</td>\n",
       "      <td>澳大利亚</td>\n",
       "      <td>8 (+3)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>14↓</td>\n",
       "      <td>山景城</td>\n",
       "      <td>15 (+3)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>15↑</td>\n",
       "      <td>荷兰</td>\n",
       "      <td>7 (+4)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>14↑</td>\n",
       "      <td>特拉维夫</td>\n",
       "      <td>15 (+4)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>15↓</td>\n",
       "      <td>墨西哥</td>\n",
       "      <td>7 (+2)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>14↑</td>\n",
       "      <td>圣保罗</td>\n",
       "      <td>15 (+5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>17↓</td>\n",
       "      <td>瑞士</td>\n",
       "      <td>6 (+2)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>17↓</td>\n",
       "      <td>芝加哥</td>\n",
       "      <td>13 (-2)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>18↓</td>\n",
       "      <td>印度尼西亚</td>\n",
       "      <td>5 (-2)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18↑</td>\n",
       "      <td>孟买</td>\n",
       "      <td>12 (+3)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>18*</td>\n",
       "      <td>越南</td>\n",
       "      <td>5 (+4)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18↑</td>\n",
       "      <td>新加坡</td>\n",
       "      <td>12 (+5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>18↑</td>\n",
       "      <td>挪威</td>\n",
       "      <td>5 (+3)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18↓</td>\n",
       "      <td>古尔冈</td>\n",
       "      <td>12 (0)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>21↓</td>\n",
       "      <td>芬兰</td>\n",
       "      <td>4 (+2)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>21↓</td>\n",
       "      <td>雷德伍德城</td>\n",
       "      <td>11 (0)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>21↓</td>\n",
       "      <td>爱尔兰</td>\n",
       "      <td>4 (+2)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>21↑</td>\n",
       "      <td>洛杉矶</td>\n",
       "      <td>11 (+2)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>23↓</td>\n",
       "      <td>阿联酋</td>\n",
       "      <td>3 (+1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>21↓</td>\n",
       "      <td>圣马特奥</td>\n",
       "      <td>11 (0)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>23↓</td>\n",
       "      <td>哥伦比亚</td>\n",
       "      <td>3 (+1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>21↑</td>\n",
       "      <td>首尔</td>\n",
       "      <td>11 (+4)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>23↓</td>\n",
       "      <td>奥地利</td>\n",
       "      <td>3 (+1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>25↑</td>\n",
       "      <td>美国剑桥</td>\n",
       "      <td>9 (+2)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>23↓</td>\n",
       "      <td>西班牙</td>\n",
       "      <td>3 (0)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>25*</td>\n",
       "      <td>奥斯汀</td>\n",
       "      <td>9 (+4)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>23↓</td>\n",
       "      <td>土耳其</td>\n",
       "      <td>3 (+1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>25*</td>\n",
       "      <td>丹佛</td>\n",
       "      <td>9 (+5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>23↓</td>\n",
       "      <td>菲律宾</td>\n",
       "      <td>3 (+1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>25*</td>\n",
       "      <td>成都</td>\n",
       "      <td>9 (+4)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>29↓</td>\n",
       "      <td>泰国</td>\n",
       "      <td>2 (0)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>29*</td>\n",
       "      <td>迈阿密</td>\n",
       "      <td>8 (+3)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>29*</td>\n",
       "      <td>比利时</td>\n",
       "      <td>2 (+1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>29*</td>\n",
       "      <td>华盛顿</td>\n",
       "      <td>8 (+3)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>29↓</td>\n",
       "      <td>尼日利亚</td>\n",
       "      <td>2 (0)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>29↓</td>\n",
       "      <td>丹麦</td>\n",
       "      <td>2 (0)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>29*</td>\n",
       "      <td>爱沙尼亚</td>\n",
       "      <td>2 (+1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>29*</td>\n",
       "      <td>智利</td>\n",
       "      <td>2 (+1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>29↓</td>\n",
       "      <td>马耳他</td>\n",
       "      <td>2 (0)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>29*</td>\n",
       "      <td>立陶宛</td>\n",
       "      <td>2 (+1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      0      1           2   3    4      5          6\n",
       "0   NaN     国家   独角兽数量（变化） NaN  NaN     城市  独角兽数量（变化）\n",
       "1    1-     美国  625 (+138) NaN   1-    旧金山  176 (+25)\n",
       "2    2-     中国   312 (+11) NaN   2↑     纽约  120 (+35)\n",
       "3    3-     印度    68 (+14) NaN   3↓     北京    90 (-1)\n",
       "4    4-     英国     46 (+7) NaN   4-     上海    69 (-2)\n",
       "5    5-     德国    36 (+10) NaN   5↑     伦敦    39 (+8)\n",
       "6    6↑    以色列     24 (+7) NaN   6↓     深圳    33 (+1)\n",
       "7    7↓     法国     23 (+4) NaN   6↑   班加罗尔    33 (+5)\n",
       "8    8-    加拿大     21 (+6) NaN   8↑     柏林    23 (+6)\n",
       "9    9-     巴西     17 (+5) NaN   9↓     杭州    21 (-1)\n",
       "10  10-     韩国     15 (+5) NaN   9-     巴黎    21 (+3)\n",
       "11  11-    新加坡     12 (+5) NaN  11↑  帕洛阿尔托    19 (+7)\n",
       "12  12↑     瑞典      8 (+4) NaN  11↑     广州    19 (+9)\n",
       "13  12↑     日本      8 (+2) NaN  13↓    波士顿    17 (+5)\n",
       "14  12↑   澳大利亚      8 (+3) NaN  14↓    山景城    15 (+3)\n",
       "15  15↑     荷兰      7 (+4) NaN  14↑   特拉维夫    15 (+4)\n",
       "16  15↓    墨西哥      7 (+2) NaN  14↑    圣保罗    15 (+5)\n",
       "17  17↓     瑞士      6 (+2) NaN  17↓    芝加哥    13 (-2)\n",
       "18  18↓  印度尼西亚      5 (-2) NaN  18↑     孟买    12 (+3)\n",
       "19  18*     越南      5 (+4) NaN  18↑    新加坡    12 (+5)\n",
       "20  18↑     挪威      5 (+3) NaN  18↓    古尔冈     12 (0)\n",
       "21  21↓     芬兰      4 (+2) NaN  21↓  雷德伍德城     11 (0)\n",
       "22  21↓    爱尔兰      4 (+2) NaN  21↑    洛杉矶    11 (+2)\n",
       "23  23↓    阿联酋      3 (+1) NaN  21↓   圣马特奥     11 (0)\n",
       "24  23↓   哥伦比亚      3 (+1) NaN  21↑     首尔    11 (+4)\n",
       "25  23↓    奥地利      3 (+1) NaN  25↑   美国剑桥     9 (+2)\n",
       "26  23↓    西班牙       3 (0) NaN  25*    奥斯汀     9 (+4)\n",
       "27  23↓    土耳其      3 (+1) NaN  25*     丹佛     9 (+5)\n",
       "28  23↓    菲律宾      3 (+1) NaN  25*     成都     9 (+4)\n",
       "29  29↓     泰国       2 (0) NaN  29*    迈阿密     8 (+3)\n",
       "30  29*    比利时      2 (+1) NaN  29*    华盛顿     8 (+3)\n",
       "31  29↓   尼日利亚       2 (0) NaN  NaN    NaN        NaN\n",
       "32  29↓     丹麦       2 (0) NaN  NaN    NaN        NaN\n",
       "33  29*   爱沙尼亚      2 (+1) NaN  NaN    NaN        NaN\n",
       "34  29*     智利      2 (+1) NaN  NaN    NaN        NaN\n",
       "35  29↓    马耳他       2 (0) NaN  NaN    NaN        NaN\n",
       "36  29*    立陶宛      2 (+1) NaN  NaN    NaN        NaN"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_hurun = pd.read_html('https://hurun.net/zh-CN/Info/Detail?num=L9SQPH9FKJB1')[1]\n",
    "df_hurun"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "24855ac6",
   "metadata": {},
   "source": [
    "### 数据写入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "66a3d2fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_hurun.to_excel('output_hurun.xlsx',index = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "189d9a43",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_hurun.to_csv('output_hurun.csv',index = False,encoding = 'UTF8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "67ef4611",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_hurun.to_csv('output_hurun.txt',sep='\\t')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "7c69e6a1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Defaulting to user installation because normal site-packages is not writeable\n",
      "Requirement already satisfied: tabulate in d:\\download\\anaconda\\lib\\site-packages (0.8.9)\n"
     ]
    }
   ],
   "source": [
    "!pip install tabulate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "d114c7d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "|    | 0   | 1          | 2                  |   3 | 4   | 5          | 6                  |\n",
      "|---:|:----|:-----------|:-------------------|----:|:----|:-----------|:-------------------|\n",
      "|  0 | nan | 国家       | 独角兽数量（变化） | nan | nan | 城市       | 独角兽数量（变化） |\n",
      "|  1 | 1-  | 美国       | 625 (+138)         | nan | 1-  | 旧金山     | 176 (+25)          |\n",
      "|  2 | 2-  | 中国       | 312 (+11)          | nan | 2↑  | 纽约       | 120 (+35)          |\n",
      "|  3 | 3-  | 印度       | 68 (+14)           | nan | 3↓  | 北京       | 90 (-1)            |\n",
      "|  4 | 4-  | 英国       | 46 (+7)            | nan | 4-  | 上海       | 69 (-2)            |\n",
      "|  5 | 5-  | 德国       | 36 (+10)           | nan | 5↑  | 伦敦       | 39 (+8)            |\n",
      "|  6 | 6↑  | 以色列     | 24 (+7)            | nan | 6↓  | 深圳       | 33 (+1)            |\n",
      "|  7 | 7↓  | 法国       | 23 (+4)            | nan | 6↑  | 班加罗尔   | 33 (+5)            |\n",
      "|  8 | 8-  | 加拿大     | 21 (+6)            | nan | 8↑  | 柏林       | 23 (+6)            |\n",
      "|  9 | 9-  | 巴西       | 17 (+5)            | nan | 9↓  | 杭州       | 21 (-1)            |\n",
      "| 10 | 10- | 韩国       | 15 (+5)            | nan | 9-  | 巴黎       | 21 (+3)            |\n",
      "| 11 | 11- | 新加坡     | 12 (+5)            | nan | 11↑ | 帕洛阿尔托 | 19 (+7)            |\n",
      "| 12 | 12↑ | 瑞典       | 8 (+4)             | nan | 11↑ | 广州       | 19 (+9)            |\n",
      "| 13 | 12↑ | 日本       | 8 (+2)             | nan | 13↓ | 波士顿     | 17 (+5)            |\n",
      "| 14 | 12↑ | 澳大利亚   | 8 (+3)             | nan | 14↓ | 山景城     | 15 (+3)            |\n",
      "| 15 | 15↑ | 荷兰       | 7 (+4)             | nan | 14↑ | 特拉维夫   | 15 (+4)            |\n",
      "| 16 | 15↓ | 墨西哥     | 7 (+2)             | nan | 14↑ | 圣保罗     | 15 (+5)            |\n",
      "| 17 | 17↓ | 瑞士       | 6 (+2)             | nan | 17↓ | 芝加哥     | 13 (-2)            |\n",
      "| 18 | 18↓ | 印度尼西亚 | 5 (-2)             | nan | 18↑ | 孟买       | 12 (+3)            |\n",
      "| 19 | 18* | 越南       | 5 (+4)             | nan | 18↑ | 新加坡     | 12 (+5)            |\n",
      "| 20 | 18↑ | 挪威       | 5 (+3)             | nan | 18↓ | 古尔冈     | 12 (0)             |\n",
      "| 21 | 21↓ | 芬兰       | 4 (+2)             | nan | 21↓ | 雷德伍德城 | 11 (0)             |\n",
      "| 22 | 21↓ | 爱尔兰     | 4 (+2)             | nan | 21↑ | 洛杉矶     | 11 (+2)            |\n",
      "| 23 | 23↓ | 阿联酋     | 3 (+1)             | nan | 21↓ | 圣马特奥   | 11 (0)             |\n",
      "| 24 | 23↓ | 哥伦比亚   | 3 (+1)             | nan | 21↑ | 首尔       | 11 (+4)            |\n",
      "| 25 | 23↓ | 奥地利     | 3 (+1)             | nan | 25↑ | 美国剑桥   | 9 (+2)             |\n",
      "| 26 | 23↓ | 西班牙     | 3 (0)              | nan | 25* | 奥斯汀     | 9 (+4)             |\n",
      "| 27 | 23↓ | 土耳其     | 3 (+1)             | nan | 25* | 丹佛       | 9 (+5)             |\n",
      "| 28 | 23↓ | 菲律宾     | 3 (+1)             | nan | 25* | 成都       | 9 (+4)             |\n",
      "| 29 | 29↓ | 泰国       | 2 (0)              | nan | 29* | 迈阿密     | 8 (+3)             |\n",
      "| 30 | 29* | 比利时     | 2 (+1)             | nan | 29* | 华盛顿     | 8 (+3)             |\n",
      "| 31 | 29↓ | 尼日利亚   | 2 (0)              | nan | nan | nan        | nan                |\n",
      "| 32 | 29↓ | 丹麦       | 2 (0)              | nan | nan | nan        | nan                |\n",
      "| 33 | 29* | 爱沙尼亚   | 2 (+1)             | nan | nan | nan        | nan                |\n",
      "| 34 | 29* | 智利       | 2 (+1)             | nan | nan | nan        | nan                |\n",
      "| 35 | 29↓ | 马耳他     | 2 (0)              | nan | nan | nan        | nan                |\n",
      "| 36 | 29* | 立陶宛     | 2 (+1)             | nan | nan | nan        | nan                |\n"
     ]
    }
   ],
   "source": [
    "print(df_hurun.to_markdown())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "e25e9660",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'<table border=\"1\" class=\"dataframe\">\\n  <thead>\\n    <tr style=\"text-align: right;\">\\n      <th></th>\\n      <th>0</th>\\n      <th>1</th>\\n      <th>2</th>\\n      <th>3</th>\\n      <th>4</th>\\n      <th>5</th>\\n      <th>6</th>\\n    </tr>\\n  </thead>\\n  <tbody>\\n    <tr>\\n      <th>0</th>\\n      <td>NaN</td>\\n      <td>国家</td>\\n      <td>独角兽数量（变化）</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>城市</td>\\n      <td>独角兽数量（变化）</td>\\n    </tr>\\n    <tr>\\n      <th>1</th>\\n      <td>1-</td>\\n      <td>美国</td>\\n      <td>625 (+138)</td>\\n      <td>NaN</td>\\n      <td>1-</td>\\n      <td>旧金山</td>\\n      <td>176 (+25)</td>\\n    </tr>\\n    <tr>\\n      <th>2</th>\\n      <td>2-</td>\\n      <td>中国</td>\\n      <td>312 (+11)</td>\\n      <td>NaN</td>\\n      <td>2↑</td>\\n      <td>纽约</td>\\n      <td>120 (+35)</td>\\n    </tr>\\n    <tr>\\n      <th>3</th>\\n      <td>3-</td>\\n      <td>印度</td>\\n      <td>68 (+14)</td>\\n      <td>NaN</td>\\n      <td>3↓</td>\\n      <td>北京</td>\\n      <td>90 (-1)</td>\\n    </tr>\\n    <tr>\\n      <th>4</th>\\n      <td>4-</td>\\n      <td>英国</td>\\n      <td>46 (+7)</td>\\n      <td>NaN</td>\\n      <td>4-</td>\\n      <td>上海</td>\\n      <td>69 (-2)</td>\\n    </tr>\\n    <tr>\\n      <th>5</th>\\n      <td>5-</td>\\n      <td>德国</td>\\n      <td>36 (+10)</td>\\n      <td>NaN</td>\\n      <td>5↑</td>\\n      <td>伦敦</td>\\n      <td>39 (+8)</td>\\n    </tr>\\n    <tr>\\n      <th>6</th>\\n      <td>6↑</td>\\n      <td>以色列</td>\\n      <td>24 (+7)</td>\\n      <td>NaN</td>\\n      <td>6↓</td>\\n      <td>深圳</td>\\n      <td>33 (+1)</td>\\n    </tr>\\n    <tr>\\n      <th>7</th>\\n      <td>7↓</td>\\n      <td>法国</td>\\n      <td>23 (+4)</td>\\n      <td>NaN</td>\\n      <td>6↑</td>\\n      <td>班加罗尔</td>\\n      <td>33 (+5)</td>\\n    </tr>\\n    <tr>\\n      <th>8</th>\\n      <td>8-</td>\\n      <td>加拿大</td>\\n      <td>21 (+6)</td>\\n      <td>NaN</td>\\n      <td>8↑</td>\\n      <td>柏林</td>\\n      <td>23 (+6)</td>\\n    </tr>\\n    <tr>\\n      <th>9</th>\\n      <td>9-</td>\\n      <td>巴西</td>\\n      <td>17 (+5)</td>\\n      <td>NaN</td>\\n      <td>9↓</td>\\n      <td>杭州</td>\\n      <td>21 (-1)</td>\\n    </tr>\\n    <tr>\\n      <th>10</th>\\n      <td>10-</td>\\n      <td>韩国</td>\\n      <td>15 (+5)</td>\\n      <td>NaN</td>\\n      <td>9-</td>\\n      <td>巴黎</td>\\n      <td>21 (+3)</td>\\n    </tr>\\n    <tr>\\n      <th>11</th>\\n      <td>11-</td>\\n      <td>新加坡</td>\\n      <td>12 (+5)</td>\\n      <td>NaN</td>\\n      <td>11↑</td>\\n      <td>帕洛阿尔托</td>\\n      <td>19 (+7)</td>\\n    </tr>\\n    <tr>\\n      <th>12</th>\\n      <td>12↑</td>\\n      <td>瑞典</td>\\n      <td>8 (+4)</td>\\n      <td>NaN</td>\\n      <td>11↑</td>\\n      <td>广州</td>\\n      <td>19 (+9)</td>\\n    </tr>\\n    <tr>\\n      <th>13</th>\\n      <td>12↑</td>\\n      <td>日本</td>\\n      <td>8 (+2)</td>\\n      <td>NaN</td>\\n      <td>13↓</td>\\n      <td>波士顿</td>\\n      <td>17 (+5)</td>\\n    </tr>\\n    <tr>\\n      <th>14</th>\\n      <td>12↑</td>\\n      <td>澳大利亚</td>\\n      <td>8 (+3)</td>\\n      <td>NaN</td>\\n      <td>14↓</td>\\n      <td>山景城</td>\\n      <td>15 (+3)</td>\\n    </tr>\\n    <tr>\\n      <th>15</th>\\n      <td>15↑</td>\\n      <td>荷兰</td>\\n      <td>7 (+4)</td>\\n      <td>NaN</td>\\n      <td>14↑</td>\\n      <td>特拉维夫</td>\\n      <td>15 (+4)</td>\\n    </tr>\\n    <tr>\\n      <th>16</th>\\n      <td>15↓</td>\\n      <td>墨西哥</td>\\n      <td>7 (+2)</td>\\n      <td>NaN</td>\\n      <td>14↑</td>\\n      <td>圣保罗</td>\\n      <td>15 (+5)</td>\\n    </tr>\\n    <tr>\\n      <th>17</th>\\n      <td>17↓</td>\\n      <td>瑞士</td>\\n      <td>6 (+2)</td>\\n      <td>NaN</td>\\n      <td>17↓</td>\\n      <td>芝加哥</td>\\n      <td>13 (-2)</td>\\n    </tr>\\n    <tr>\\n      <th>18</th>\\n      <td>18↓</td>\\n      <td>印度尼西亚</td>\\n      <td>5 (-2)</td>\\n      <td>NaN</td>\\n      <td>18↑</td>\\n      <td>孟买</td>\\n      <td>12 (+3)</td>\\n    </tr>\\n    <tr>\\n      <th>19</th>\\n      <td>18*</td>\\n      <td>越南</td>\\n      <td>5 (+4)</td>\\n      <td>NaN</td>\\n      <td>18↑</td>\\n      <td>新加坡</td>\\n      <td>12 (+5)</td>\\n    </tr>\\n    <tr>\\n      <th>20</th>\\n      <td>18↑</td>\\n      <td>挪威</td>\\n      <td>5 (+3)</td>\\n      <td>NaN</td>\\n      <td>18↓</td>\\n      <td>古尔冈</td>\\n      <td>12 (0)</td>\\n    </tr>\\n    <tr>\\n      <th>21</th>\\n      <td>21↓</td>\\n      <td>芬兰</td>\\n      <td>4 (+2)</td>\\n      <td>NaN</td>\\n      <td>21↓</td>\\n      <td>雷德伍德城</td>\\n      <td>11 (0)</td>\\n    </tr>\\n    <tr>\\n      <th>22</th>\\n      <td>21↓</td>\\n      <td>爱尔兰</td>\\n      <td>4 (+2)</td>\\n      <td>NaN</td>\\n      <td>21↑</td>\\n      <td>洛杉矶</td>\\n      <td>11 (+2)</td>\\n    </tr>\\n    <tr>\\n      <th>23</th>\\n      <td>23↓</td>\\n      <td>阿联酋</td>\\n      <td>3 (+1)</td>\\n      <td>NaN</td>\\n      <td>21↓</td>\\n      <td>圣马特奥</td>\\n      <td>11 (0)</td>\\n    </tr>\\n    <tr>\\n      <th>24</th>\\n      <td>23↓</td>\\n      <td>哥伦比亚</td>\\n      <td>3 (+1)</td>\\n      <td>NaN</td>\\n      <td>21↑</td>\\n      <td>首尔</td>\\n      <td>11 (+4)</td>\\n    </tr>\\n    <tr>\\n      <th>25</th>\\n      <td>23↓</td>\\n      <td>奥地利</td>\\n      <td>3 (+1)</td>\\n      <td>NaN</td>\\n      <td>25↑</td>\\n      <td>美国剑桥</td>\\n      <td>9 (+2)</td>\\n    </tr>\\n    <tr>\\n      <th>26</th>\\n      <td>23↓</td>\\n      <td>西班牙</td>\\n      <td>3 (0)</td>\\n      <td>NaN</td>\\n      <td>25*</td>\\n      <td>奥斯汀</td>\\n      <td>9 (+4)</td>\\n    </tr>\\n    <tr>\\n      <th>27</th>\\n      <td>23↓</td>\\n      <td>土耳其</td>\\n      <td>3 (+1)</td>\\n      <td>NaN</td>\\n      <td>25*</td>\\n      <td>丹佛</td>\\n      <td>9 (+5)</td>\\n    </tr>\\n    <tr>\\n      <th>28</th>\\n      <td>23↓</td>\\n      <td>菲律宾</td>\\n      <td>3 (+1)</td>\\n      <td>NaN</td>\\n      <td>25*</td>\\n      <td>成都</td>\\n      <td>9 (+4)</td>\\n    </tr>\\n    <tr>\\n      <th>29</th>\\n      <td>29↓</td>\\n      <td>泰国</td>\\n      <td>2 (0)</td>\\n      <td>NaN</td>\\n      <td>29*</td>\\n      <td>迈阿密</td>\\n      <td>8 (+3)</td>\\n    </tr>\\n    <tr>\\n      <th>30</th>\\n      <td>29*</td>\\n      <td>比利时</td>\\n      <td>2 (+1)</td>\\n      <td>NaN</td>\\n      <td>29*</td>\\n      <td>华盛顿</td>\\n      <td>8 (+3)</td>\\n    </tr>\\n    <tr>\\n      <th>31</th>\\n      <td>29↓</td>\\n      <td>尼日利亚</td>\\n      <td>2 (0)</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n    </tr>\\n    <tr>\\n      <th>32</th>\\n      <td>29↓</td>\\n      <td>丹麦</td>\\n      <td>2 (0)</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n    </tr>\\n    <tr>\\n      <th>33</th>\\n      <td>29*</td>\\n      <td>爱沙尼亚</td>\\n      <td>2 (+1)</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n    </tr>\\n    <tr>\\n      <th>34</th>\\n      <td>29*</td>\\n      <td>智利</td>\\n      <td>2 (+1)</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n    </tr>\\n    <tr>\\n      <th>35</th>\\n      <td>29↓</td>\\n      <td>马耳他</td>\\n      <td>2 (0)</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n    </tr>\\n    <tr>\\n      <th>36</th>\\n      <td>29*</td>\\n      <td>立陶宛</td>\\n      <td>2 (+1)</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n      <td>NaN</td>\\n    </tr>\\n  </tbody>\\n</table>'"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_hurun.to_html()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b1d8c5fd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
